<?php 
$pPageIsPublic = false;
include '../_common.php';
$_SESSION["m1"]="content";
$_SESSION["m2"]="page-list";

$table   = 'Page';
$pTitle  = "New {$table}";
$pButton = 'Save';
$action  = 'add';
$id 	 = intval($_REQUEST['id']);

$seo	 = NULL;
	
$objPage = new Page();
$objPage ->setUid($id);
if ($objPage ->load()) {
	//$seo = json_decode($objPage ->seo);
	$pTitle  = "Edit {$table}";
	$pButton = 'Update';
	$action  = 'edit';
	
}


if (isset($_POST['submit'])) {
	$objPage ->setAuto($_POST);
	
	//$objPage ->seo = arr2json($_POST, array('metaTitle', 'metaDescription', 'metaKeyword', 'friendlyUrl'));
	
	
	$objPage ->parentId = PARENT_PAGE;		
	if ($_POST['action'] == 'edit') {
		$objPage ->getConnection();
		$objPage ->update();
		Tzn::redirect("{$_SERVER['PHP_SELF']}?id={$objPage ->id}", "{$table} has been updated.");
	} elseif ($_POST['action'] == 'add') {		
		Tzn::redirect("page-list.php", "Disabled function.", 1);
		/*$objPage ->add();
		Tzn::redirect("{$_SERVER['PHP_SELF']}?id={$objPage ->id}", "{$table} has been added.");*/
	}
}

?>
<?php include("header.php"); ?>
<script type="text/javascript">
$(document).ready(function(){
	$('#frmMain').validate();
});
</script>   
<?php include("sidebar.php"); ?>
<ul id="subnav" >
	<li class="noborder" ><a class="back" href="page-list.php" > Back </a></li>
	<!-- li class="noborder" ><a class="add" href="<?php echo $_SERVER['PHP_SELF']?>?pid=<?php echo $pid  ?>" > Add Career</a></li-->
</ul>
<div id="list">
<h2> <?php echo $pTitle;?> </h2>
			<form action="" method="post" name = "frmMain" id = "frmMain" enctype="multipart/form-data"  >
				<table cellpadding="0" cellspacing="0" class="table-form"  >
					<tr>
						<th width="12%">Title: </th>
						<td><?php $objPage ->qText('title', '', 'width:98%;background:#eee;color:#333;', 'class="required" disabled'); ?></td>
					</tr>					
					<tr>
						<th>Description: </th>
						<td><?php $objPage ->qEditor('description', array('toolbar' => 'custom') ); ?></td>
					</tr>					
					<?php #$objPage ->pSEO();   ?>
					<!-- tr>
						<th>Status: </th>
						<td><?php $objPage ->arrayToSelect($objPage ->_arrStatus, 'status', $objPage ->status, false, 'width:100px', '');?></td>
					</tr-->
				</table><br/>
		        <input type="submit" name="submit"  value="Save" />&nbsp;
		        <input type="button" name="cancel" value="Cancel" onclick="location.href='page-list.php'" />
		        <input type="hidden" name="id" value="<?php echo $id  ?>"  />
		        <input type="hidden" name="action" value="<?php echo $action; ?>" />
			</form>
</div>
<div class="clear"></div>    
<?php include("footer.php"); ?>
